package net.zjitc.service.impl;

import net.zjitc.mapper.CategoryMapper;
import net.zjitc.pojo.api.ApiResult;
import net.zjitc.pojo.api.PageResult;
import net.zjitc.pojo.api.Result;
import net.zjitc.pojo.dto.query.extend.CategoryQueryDto;
import net.zjitc.pojo.entity.Category;
import net.zjitc.service.CategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

//书籍类别
@Service
public class CategoryServiceImpl implements CategoryService {

    @Resource
    private CategoryMapper categoryMapper;
    //书籍类别增加
    @Override
    public Result<Void> save(Category category) {
        categoryMapper.save(category);
        return ApiResult.success();
    }
    //删除
    @Override
    public Result<Void> batchDelete(List<Integer> ids) {
        categoryMapper.batchDelete(ids);
        return ApiResult.success();
    }
    //修改
    @Override
    public Result<Void> update(Category category) {
        categoryMapper.update(category);
        return ApiResult.success();
    }
    //查询
    @Override
    public Result<List<Category>> query(CategoryQueryDto categoryQueryDto) {
        List<Category> noticeList = categoryMapper.query(categoryQueryDto);
        Integer totalCount = categoryMapper.queryCount(categoryQueryDto);
        return PageResult.success(noticeList, totalCount);
    }

}
